<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>love-u.js文档</title>
    <style>
        h3 {
            border-left: 4px solid #c33;
            padding: 5px 10px;
            background-color: #f5f5f5;
        }
    </style>
</head>

<body>
    <div style="width: 600px;margin: 30px auto;">
        <div style="text-align: center;">
            <input type="search" id="key" style="padding-left:10px;height: 35px;width: 300px;">
        </div>
        $CONTENT$
    </div>
</body>
<script>
    let key = document.querySelector("#key")
    let h3List = document.querySelectorAll("h3")
    key.oninput = () => {
        for (let i = 0; i < h3List.length; i++) {
            const element = h3List[i];
            element.style.display = element.textContent.includes(key.value) ? 'block' : 'none'
        }
    }
</script>

</html>